package com.lemon.core.common.web.notify.dingding.bean;

import com.lemon.core.common.web.notify.dingding.DingDingUtils;

import java.util.Date;
import java.util.SortedMap;

/**
 * @author lottery
 * @ClassName DingNotifyData
 * @desc 通知消息实体类
 * @Date 2018/11/2 16:12
 * @Version 1.0
 **/
public class DingNotifyData {

    public interface Constants {

        public static final String TEXT_TYPE = "text";

        public static final String LINK_TYPE = "link";

        public static final String MARKDOWN_TYPE = "markdown";

        public static final String ACTIONCARD_TYPE = "actionCard";
    }

    /**
     * 消息类型
     */
    private String msgtype;

    /**
     * 标题
     */
    private String title;

    /**
     * 副标题
     */
    private String subTitle;

    /**
     * 消息内容
     */
    private String content;

    /**
     * 被@人的手机号码,都好间隔
     */
    private String atMobiles;

    /**
     * 是否@所有人
     */
    private Boolean atAll;

    /**
     * 点击消息跳转的URL
     */
    private String messageUrl;

    /**
     * 图片URL
     */
    private String picUrl;

    /**
     * 单个按钮的方案
     */
    private String singleTitle;

    /**
     * 点击singleTitle按钮触发的URL
     */
    private String singleURL;

    /**按钮的信息：title-按钮方案，actionURL-点击按钮触发的URL
     *
     */
    private String[] btns;

    /**
     * 0-按钮竖直排列，1-按钮横向排列
     */
    private String btnOrientation;

    /**
     *
     */
    private String hideAvatar;

    /**
     * 0-正常发消息者头像，1-隐藏发消息者头像
     */
    private String description;

    private SortedMap<String, Object> commonData;

    /**
     * 消息创建时间
     */
    private Date createTime;

    // -------------------- 构建text类型消息 --------------------

    public DingNotifyData buildTextMsg(String content) {
        this.content = content;
        this.atAll = false;
        this.msgtype = Constants.TEXT_TYPE;
        return this;
    }

    public DingNotifyData buildTextMsg(String content, String atMobiles) {
        this.content = content;
        this.atMobiles = atMobiles;
        this.atAll = false;
        this.msgtype = Constants.TEXT_TYPE;
        return this;
    }

    public DingNotifyData buildTextMsg(String content, Boolean atAll) {
        this.content = content;
        this.atAll = atAll;
        this.msgtype = Constants.TEXT_TYPE;
        return this;
    }

    // -------------------- 构建text类型消息 --------------------


    // -------------------- 构建link类型消息 --------------------

    public DingNotifyData buildLinkMsg(String title, String content, String messageUrl) {
        this.title = title;
        this.content = content;
        this.messageUrl = messageUrl;
        this.msgtype = Constants.LINK_TYPE;
        return this;
    }

    public DingNotifyData buildLinkMsg(String title, String content, String messageUrl, String picUrl) {
        this.title = title;
        this.content = content;
        this.messageUrl = messageUrl;
        this.picUrl = picUrl;
        this.msgtype = Constants.LINK_TYPE;
        return this;
    }

    // -------------------- 构建link类型消息 --------------------


    // -------------------- 构建markdown类型消息 --------------------

    public DingNotifyData buildMarkdownMsg(String title, String content) {
        this.title = title;
        this.content = content;
        this.atAll = false;
        this.msgtype = Constants.MARKDOWN_TYPE;
        return this;
    }

    public DingNotifyData buildMarkdownMsg(String title, String content, String atMobiles) {
        this.title = title;
        this.content = content;
        this.atMobiles = atMobiles;
        this.atAll = false;
        this.msgtype = Constants.MARKDOWN_TYPE;
        return this;
    }

    public DingNotifyData buildMarkdownMsg(String title, String content, Boolean atAll) {
        this.title = title;
        this.content = content;
        this.atAll = atAll;
        this.msgtype = Constants.MARKDOWN_TYPE;
        return this;
    }

    // -------------------- 构建markdown类型消息 --------------------


    // -------------------- 构建ActionCard类型消息 --------------------

    public DingNotifyData buildActionCardMsg(String title, String content, String singleTitle, String singleURL) {
        this.title = title;
        this.content = content;
        this.hideAvatar = "0";
        this.btnOrientation = "0";
        this.singleTitle = singleTitle;
        this.singleURL = singleURL;
        this.msgtype = Constants.ACTIONCARD_TYPE;
        return this;
    }

    // -------------------- 构建ActionCard类型消息 --------------------


    public String getMsgtype() {
        return msgtype;
    }

    public void setMsgtype(String msgtype) {
        this.msgtype = msgtype;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSubTitle() {
        return subTitle;
    }

    public void setSubTitle(String subTitle) {
        this.subTitle = subTitle;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getAtMobiles() {
        return atMobiles;
    }

    public void setAtMobiles(String atMobiles) {
        this.atMobiles = atMobiles;
    }

    public Boolean getAtAll() {
        return atAll;
    }

    public void setAtAll(Boolean atAll) {
        this.atAll = atAll;
    }

    public String getMessageUrl() {
        return messageUrl;
    }

    public void setMessageUrl(String messageUrl) {
        this.messageUrl = messageUrl;
    }

    public String getPicUrl() {
        return picUrl;
    }

    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }

    public String getSingleTitle() {
        return singleTitle;
    }

    public void setSingleTitle(String singleTitle) {
        this.singleTitle = singleTitle;
    }

    public String getSingleURL() {
        return singleURL;
    }

    public void setSingleURL(String singleURL) {
        this.singleURL = singleURL;
    }

    public String[] getBtns() {
        return btns;
    }

    public void setBtns(String[] btns) {
        this.btns = btns;
    }

    public String getBtnOrientation() {
        return btnOrientation;
    }

    public void setBtnOrientation(String btnOrientation) {
        this.btnOrientation = btnOrientation;
    }

    public String getHideAvatar() {
        return hideAvatar;
    }

    public void setHideAvatar(String hideAvatar) {
        this.hideAvatar = hideAvatar;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public SortedMap<String, Object> getCommonData() {
        return commonData;
    }

    public void setCommonData(SortedMap<String, Object> commonData) {
        this.commonData = commonData;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
